/********************************************************/
/*	Copyright (C) 2012 Gong Li Bin			*/
/*	Project:	MapReduce			*/
/*	Author:		gong_libin			*/
/*	Date:		2013_05_14			*/
/*	File:		MrAdmin.h			*/
/********************************************************/

#ifndef	_MRADMIN_H
#define	_MRADMIN_H

#include "MrDb.h"
#include "MrDef.h"
#include "MrAvg.h"
#include "MrCpu.h"
#include "MrDsk.h"
#include "MrIos.h"
#include "MrMem.h"
#include "MrPro.h"
#include "MrSet.h"
#include "MrUdp.h"
#include "MrUtl.h"
#include "MrTmap.h"
#include "MrPoll.h"
#include "MrPipe.h"
#include "MrConf.h"
#include "MrTime.h"
#include "MrMulti.h"
#include "MrThread.h"
#include "MrRwLock.h"

#include <getopt.h>
#include <signal.h>
#include <sys/wait.h>

#define	MR_AD_VERSION			"MrAdmin-2.0.0"
#define	MR_AD_CONFIG			"SELECT Port,MultiAddr,MultiPort FROM %s.%s WHERE HostID=%s"

typedef struct tagMrDevice
{
	UINT m_uiID;
	time_t m_ulTime;
	MRAVG_S m_stAvg;
	MRCPU_S m_stCpu;
	MRIOS_S m_stIos;
	MRMMR_S m_stMem[MR_CMD];
	MRDSK_S m_stDsk[MR_CMD];
}MRDEVICE_S;

typedef struct tagMrAdminConf
{
	char m_szPort[MR_VALUE];
	char m_szMultiAddr[MR_VALUE];
	char m_szMultiPort[MR_VALUE];
}MRADMINCONF_S;

void MrAdminQuit(int iSignal);
void MrAdminHelp(char* pszProc);
int MrAdminConfig(char* pszConf);
void* MrAdminMultiCore(void* pNULL);
void* MrAdminAcceptCore(void* pNULL);
int MrAdminCompAvg(const void* pOne, const void* pTwo);
int MrAdminCompCpu(const void* pOne, const void* pTwo);
int MrAdminCompDsk(const void* pOne, const void* pTwo);
int MrAdminCompIos(const void* pOne, const void* pTwo);
int MrAdminCompMem(const void* pOne, const void* pTwo);

#endif /* _MRADMIN_H */
